var uniquePaths = function (m, n) {
  // dp[0][0]=1
  // dp[i][j] 共有路径总数
  // i=0 j>0  dp[0][j] = 1
  // i>0 j=0  dp[i][0] = 1
  //i>0 j>0 dp[i][j] = dp[i-1][j] + dp[i][j-1]
  let dp = []
  for (var i = 0; i < m; i++) {
    dp[i] = []
    for (var j = 0; j < n; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 1
      } else {
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
      }
    }
  }
  return dp[m - 1][n - 1]
};
console.log(uniquePaths(3,3));